{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "58504e50",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import IL Data\n",
    "import pandas as pd\n",
    "IL_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\\\\\IL_delegations.xlsx\")\n",
    "IL_delegations_dict = IL_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of content provisions by type\n",
    "il_delegations = 0\n",
    "il_procedures = 0\n",
    "il_consent = 0\n",
    "il_approval = 0\n",
    "\n",
    "for delegation in IL_delegations_dict:\n",
    "    il_delegations +=1\n",
    "    \n",
    "    if delegation['consent'] > 0:\n",
    "        il_consent +=1\n",
    "    \n",
    "    if delegation['approval'] > 0:\n",
    "        il_approval +=1\n",
    "    \n",
    "il_procedures = il_consent + il_approval"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "85eab6f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import UK Data\n",
    "UK_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\UK_delegations.xlsx\")\n",
    "UK_delegations_dict = UK_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of content provisions by type\n",
    "uk_delegations = 0\n",
    "uk_procedures = 0\n",
    "uk_consent = 0\n",
    "uk_approval = 0\n",
    "\n",
    "for delegation in UK_delegations_dict:\n",
    "    uk_delegations +=1\n",
    "    \n",
    "    if delegation['consent'] > 0:\n",
    "        uk_consent +=1\n",
    "    \n",
    "    if delegation['approval'] > 0:\n",
    "        uk_approval +=1\n",
    "\n",
    "uk_procedures = uk_consent + uk_approval    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2a47cc7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------------------  --  ------------------  ------  ------------------\n",
      "Type of Procedure       UK  UK_percentage       Israel  Israel_Percentage\n",
      "executive_consent       14  1.9943019943019942  45      18.367346938775512\n",
      "parliamentary_approval  43  6.1253561253561255  56      22.857142857142858\n",
      "total                   57  8.11965811965812    101     41.224489795918366\n",
      "----------------------  --  ------------------  ------  ------------------\n"
     ]
    }
   ],
   "source": [
    "#create table 5 using tabulate\n",
    "from tabulate import tabulate\n",
    "\n",
    "table = [['Type of Procedure', 'UK', 'UK_percentage', 'Israel', 'Israel_Percentage'], \n",
    "         ['executive_consent', uk_consent, uk_consent/uk_delegations*100, il_consent, il_consent/il_delegations*100],\n",
    "         ['parliamentary_approval', uk_approval, uk_approval/uk_delegations*100, il_approval, il_approval/il_delegations*100],\n",
    "         ['total', uk_procedures, uk_procedures/uk_delegations*100, il_procedures, il_procedures/il_delegations*100]] \n",
    "\n",
    "print(tabulate(table))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39074015",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
